package labox.innovation.gameserver.network.clientpackets;

import labox.innovation.gameserver.model.actor.instance.FuzePcInstance;
import labox.innovation.gameserver.network.SystemMessageId;
import labox.innovation.gameserver.network.serverpackets.SearchFriendPacket;
import labox.innovation.gameserver.network.serverpackets.SystemMessage;

/**
 * @author ljsh
 * @date 2010-4-1
 * @version 1.0
 * @description 关于真征友的客户端数据包
 */
public class RequestSearchFriends extends L2GameClientPacket {
	private static final String _C__RequestSearchFriends = "[C] RequestSearchFriends";

	private int province;// 省

	private int city;// 市

	private int start_level;// 等级下限

	private int end_level;// 等级上限

	private int sex;// 性别0为男1为女

	private int classid;// 职业

	@Override
	public String getType() {
		return _C__RequestSearchFriends;
	}

	@Override
	protected void readImpl() {
		province = readByte();
		city = readByte();
		int temp = readByte();
		switch (temp) {
		case -1:
			start_level = -1;
			end_level = -1;
			break;
		case 0:
			start_level = 0;
			end_level = 20;
			break;
		case 1:
			start_level = 21;
			end_level = 40;
			break;
		case 2:
			start_level = 41;
			end_level = 60;
			break;
		case 3:
			start_level = 61;
			end_level = 80;
			break;
		default:
			break;
		}
		sex = readByte();
		classid = readByte();
	}

	@Override
	protected void runImpl() {
		FuzePcInstance instance = getClient().getActiveChar();
		SystemMessage msg = null;
		if (instance == null) {
			return;
		}
		if (instance.getFriendInstance().getProvince() == -1 || instance.getFriendInstance().getCity() == -1) {
			msg = new SystemMessage(SystemMessageId.YOUR_MUST_SET_YOURINFO);// 没有设置基本信息
			instance.sendPacket(msg);
			return;
		}
		instance.sendPacket(new SearchFriendPacket(instance, province, city, start_level, end_level, sex, classid));// 发送查询结果

	}

}
